<template>
  <view class="top-nav">
    <view 
      v-for="(item, index) in navList" 
      :key="index" 
      :class="{ 'active': currentIndex === index }"
      @click="switchNav(index)"
    >
      {{ item }}
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue';
const currentIndex = ref(0);
const navList = ref(['要闻', '推荐', '关注流', '24小时', '娱乐', '泉州', '财经']);

const switchNav = (index) => {
  currentIndex.value = index;
};
</script>

<style scoped>
.top-nav {
  display: flex;
  background-color: #d92929;
  color: #fff;
  height: 88rpx;
  align-items: center;
}
.top-nav view {
  flex: 1;
  text-align: center;
  font-size: 32rpx;
}
.top-nav .active {
  font-weight: bold;
  border-bottom: 4rpx solid #fff;
  padding-bottom: 6rpx;
}
</style>